package main

import (
	"fmt"
	"log"

	"github.com/adrg/libvlc-go/v3/libvlc"
)

func main() {
	// 初始化 VLC 实例
	inst, err := libvlc.New()
	if err != nil {
		log.Fatalf("Failed to initialize VLC instance: %v", err)
	}
	defer inst.Release()

	// 创建媒体播放器
	player, err := inst.NewMediaPlayer()
	if err != nil {
		log.Fatalf("Failed to create media player: %v", err)
	}
	defer player.Release()

	// 创建媒体对象
	media, err := inst.NewMedia("https://api.52vmy.cn/api/video/girl") // 替换为你的视频 URL
	if err != nil {
		log.Fatalf("Failed to create media: %v", err)
	}
	defer media.Release()

	// 设置媒体到播放器
	player.SetMedia(media)

	// 播放视频
	player.Play()

	fmt.Println("Press Enter to stop playback...")
	// 等待用户输入，防止程序退出
	<-make(chan struct{})
	player.Stop()
}
